<%@ page import="net.comic.entities.Comic" %>
<%@ page import="net.comic.enums.RatingType" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="comic.show" default="Show Comic" /></title>
	    
	    <g:javascript library="pages/comic"/>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir: '')}"><g:message code="home" default="Home" /></a></span>
            <span class="menuButton"><g:link class="list" action="list"><g:message code="comic.list" default="Comic List" /></g:link></span>
            <span class="menuButton"><g:link class="create" action="create"><g:message code="comic.new" default="New Comic" /></g:link></span>
        </div>
        <div class="body">
            <h1><g:message code="comic.show" default="Show Comic" /></h1>
            <span id="allStar-cap"></span>
			<span id="allStar-wrapper">
				<g:select id="allRateValue" name="allRateValue" from="${RatingType.values()}" key="key"/>
			</span>
            <g:if test="${flash.message}">
       		     <div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}" /></div>
            </g:if>
            <g:form>
				<table>
				       <tr>
				            <td><g:message code="comic.name" default="Name" />:</td>
				            <td>${fieldValue(bean: comicInstance, field: "name")}</td>
				       </tr>
				       
				       <tr>
				           <td><g:message code="comic.description" default="Description" />:</td>
				           <td>${fieldValue(bean: comicInstance, field: "description")}</td>
				       </tr>
				       
				       <tr>
				           <td><g:message code="comic.author" default="Author" />:</td>
				           <td><g:link controller="author" action="show" id="${comicInstance?.author?.id}">${comicInstance?.author?.name}</g:link></td>
				       </tr>
				       
				       <tr>
				           <td><g:message code="comic.createdBy" default="Created By" />:</td>
				           <td><g:link controller="user" action="show" id="${comicInstance?.createdBy?.id}">${comicInstance?.createdBy?.name}</g:link></td>
				       </tr>
				       
				       <tr>
				           	<td colspan="2">
					           	<img class="detail" src="${resource(dir:'uploads/superman',file:'superman_1.jpg')}" height="500px;" alt="SERGI" />
				           	</td>
				       </tr>
				       
				       <tr>
				           <td><g:message code="comic.page" default="Page" />:</td>
				           <td>
				               <ul>
				               <g:each in="${comicInstance?.page}" var="pageInstance">
				                   <li><g:link controller="page" action="show" id="${pageInstance.id}">${pageInstance.encodeAsHTML()}</g:link></li>
				               </g:each>
				               </ul>
				           </td>
				       </tr>
				       
				       <tr>
				           <td><g:message code="comic.tags" default="Tags" />:</td>
				           <td>
				               <ul>
				               <g:each in="${comicInstance?.tags}" var="tagInstance">
				                   <li><g:link controller="tag" action="show" id="${tagInstance.id}">${tagInstance.encodeAsHTML()}</g:link></li>
				               </g:each>
				               </ul>
				           </td>
				       </tr>
				       
				       <tr>
				           <td><g:message code="comic.rate" default="Rate" />:</td>
				           <td>
				           		<span id="userStar-cap"></span>
		          				<span id="userStar-wrapper">
		          					<g:select id="userRateValue" name="userRateValue"  from="${RatingType.values()}" key="key"/>
	                     			<g:hiddenField name="userRate" value="${raquest.myRate}" />
								</span>	
						   </td>
		            	</tr>
			        </table>

                <div class="buttons">
	                <g:if test="${session.userLogged != null}">
	                    <span class="button"><g:actionSubmit class="edit" action="edit" value="${message(code: 'edit', 'default': 'EDIT')}" /></span>
	                    <span class="button"><g:actionSubmit class="delete" action="delete" value="${message(code: 'delete', 'default': 'DELETE')}" onclick="return confirm('${message(code: 'delete.confirm', 'default': 'Are you sure?')}');" /></span>
	                    <span class="button"><g:actionSubmit class="rate" action="rate" value="${message(code: 'rate', 'default': 'RATE')}" /></span>
	                    <span class="button"><g:actionSubmit class="disable" action="disable" value="${message(code: 'disable', 'default': 'DISABLE')}" /></span>
	                    <span class="button"><g:actionSubmit class="enable" action="enable" value="${message(code: 'enable', 'default': 'ENABLE')}" /></span>
	                    <span class="button">
	                    	<input type="button" id="showComments" value="${message(code: 'SHOW_COMMENT', 'default': 'SHOW_COMMENT')}"/>
	                    </span>
	                    <span class="button"><g:actionSubmit class="favorite" action="favorite" value="${message(code: 'ADD_TO_FAVORITES', 'default': 'ADD_TO_FAVORITES')}" /></span>
                    </g:if>
                </div>
            
            	<g:render template="/comment/list"/>
            
                <g:hiddenField name="id" value="${comicInstance?.id}" />
                <g:hiddenField name="rate" value="${fieldValue(bean: comicInstance, field: 'rate')}" />
                
            </g:form>
    	</div>
    </body>
</html>
